import Vue from 'vue';
import Router from 'vue-router';
import Home from '../view/Home';
import Blog from '../view/Blog';
import BlogDetail from '../view/BlogDetail';
import Contact from '../view/Contact';
import Product from '../view/Product';
import ProductDetail from '../view/ProductDetail';
import History from '../view/History';
import Clear from '../view/Clear';
import WhereToBuy from '../view/WhereToBuy';

const routerPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error => error)
};
Vue.use(Router);

const Routes = [
    {
        path: '*',
        redirect: '/home'
    },
    {
        path: '/home',
        name: 'home',
        component: Home
    },
    {
        path: '/blogs',
        name: 'blog',
        component: Blog
    },
    {
        path: '/blogs/:id',
        name: 'blogDetail',
        component: BlogDetail
    },
    {
        path: '/contact-us',
        name: 'contact',
        component: Contact
    },
    {
        path: '/product',
        name: 'product',
        component: Product
    },
    {
        path: '/product/:id',
        name: 'productDetail',
        component: ProductDetail
    },
    {
        path: '/history',
        name: 'history',
        component: History
    },
    {
        path: '/cleaning-and-care',
        name: 'cleaningAndCare',
        component: Clear
    },
    {
        path: '/where-to-buy',
        name: 'whereToBuy',
        component: WhereToBuy
    }
];

const createRouter = () => new Router({
    mode: 'history',
    routes: Routes
});

const router = createRouter();

export default router;
